package com.lenovo.smartengine.service;

import com.lenovo.smartengine.MainActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

public class NotificationService {
	private Context context ;
	public NotificationService(Context context) {
		this.context = context;
	}

	public void simpleNotify(String title,String content){
		NotificationCompat.Builder build = new NotificationCompat.Builder(context);
		build.setContentTitle(title)
		.setContentText(content)
		.setTicker("AudioType")
		.setDefaults(Notification.DEFAULT_VIBRATE);//默认的铃声和震动，不过震动需要在manifest文件中授权

		Intent intent = new Intent(context,MainActivity.class);

		PendingIntent notifyPendingIntent =
				PendingIntent.getActivity(
						context,
						0,
						intent,
						PendingIntent.FLAG_UPDATE_CURRENT
						);

		build.setContentIntent(notifyPendingIntent);

		NotificationManager mNotificationManager =
				(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

		mNotificationManager.notify(1000, build.build());

	}
	

}
